<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/template/template.xhtml">

	<ui:define name="content">

		<f:view>
			<h:form>
				<br />
				<div class="middle">
					<h2>Edit user</h2>
				</div>
				<br />
				<h:messages class="myError"></h:messages>

				<h:outputText value="#{manageUserBean.updateSuccessMessage}"
					id="updSuccMessage" styleClass="middle" style="color:#890120"></h:outputText>

				<h:panelGrid class="panelGrid" columns="2">
					<h:outputText
						value="Domain(#{ub.getDomainById(ub.us.idDomain).name})"></h:outputText>
					<h:selectOneMenu id="selectDomain" value="#{ub.domain}">
						<f:selectItems value="#{ub.domains}"></f:selectItems>
					</h:selectOneMenu>
					<h:outputText value="#{msg.AD_editUser_usertype}"></h:outputText>
					<h:selectOneMenu id="selectUstype" value="#{ub.ustype}">
						<f:selectItems value="#{ub.ustypes}"></f:selectItems>
					</h:selectOneMenu>
					<h:outputText value="#{msg.AD_editUser_name}"></h:outputText>
					<h:inputText value="#{ub.us.name}" label="Name required"
						required="true"
						requiredMessage="#{msg.OM_editmeasure_requiredMessage1}"
						validatorMessage="#{msg.OM_editmeasure_requiredMessage2}">
						<f:validateRegex pattern="^([A-Z]{1}[a-z]+[ ]?[-]?)+$"
							disabled="#{not mpb.page eq 'editUser'}"></f:validateRegex>
						<f:ajax render="updSuccMessage"></f:ajax>
					</h:inputText>
					<h:outputText value="#{msg.AD_editUser_email}"></h:outputText>
					<h:inputText value="#{ub.us.email}" label="Email required"
						required="true"
						requiredMessage="#{msg.OM_editmeasure_requiredMessage4}">
						<f:validator validatorId="validators.EmailValidator"
							disabled="#{not mpb.page eq 'editUser'}"></f:validator>
						<f:ajax render="updSuccMessage"></f:ajax>
					</h:inputText>
					<h:outputText value="#{msg.AD_editUser_username}"></h:outputText>
					<h:inputText value="#{ub.us.username}" label="Username required"
						required="true"
						requiredMessage="#{msg.OM_editmeasure_requiredMessage3}">
						<f:ajax event="valueChange">
							<f:validator validatorId="validators.UsernameValidator"
								disabled="#{not mpb.page eq 'editUser'}" />
						</f:ajax>
						<f:ajax render="updSuccMessage"></f:ajax>
					</h:inputText>
					<h:outputText value="#{msg.AD_editUser_active}"></h:outputText>
					<h:selectOneMenu id="selectActive" value="#{ub.active}">
						<f:selectItems value="#{ub.isActive}"></f:selectItems>
					</h:selectOneMenu>
				</h:panelGrid>
				<br />
				<div class="middle">
					<h:commandButton class="button"
						value="#{msg.AD_editUser_resetpass}"
						actionListener="#{ub.resetPassword}" onclick=""></h:commandButton>
					<br />
					<h:commandButton class="button" value="#{msg.AD_editUser_edit}"
						actionListener="#{ub.editUser}"
						onclick="#{msg.AD_editUser_confMessage}"></h:commandButton>
					<br />

					<h:commandButton class="button" value="#{msg.AD_editUser_cancel}"
						actionListener="#{ub.goBack}" immediate="true"></h:commandButton>
				</div>

			</h:form>
		</f:view>
	</ui:define>
</ui:composition>
</html>